<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>加减计数器</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            display: flex;
            justify-content: center;
            align-items: center;
            height: 100vh;
            background-color: #f0f0f0;
        }
        .counter {
            background-color: #fff;
            padding: 20px;
            border-radius: 10px;
            box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
            text-align: center;
        }
        button {
            padding: 10px 20px;
            margin: 5px;
            font-size: 16px;
            cursor: pointer;
        }
        button:hover {
            background-color: #ddd;
        }
        #count {
            margin-top: 10px;
            font-size: 24px;
            font-weight: bold;
        }
    </style>
</head>
<body>
    <div class="counter">
        <h2>加减计数器</h2>
        <button onclick="decrement()">减</button>
        <span id="count">0</span>
        <button onclick="increment()">加</button>
    </div>

    <script>
        let count = 0; // 初始化计数器

        function increment() {
            count++; // 增加计数值
            document.getElementById('count').innerText = count; // 更新显示
        }

        function decrement() {
            count--; // 减少计数值
            document.getElementById('count').innerText = count; // 更新显示
        }
    </script>
</body>
</html>